package cn.tedu.evaluation.management.dao.persist.repository.impl;

import cn.tedu.common.pojo.vo.PageData;
import cn.tedu.common.util.PageInfoToPageDataConverter;
import cn.tedu.evaluation.management.dao.persist.mapper.CommentMapper;
import cn.tedu.evaluation.management.dao.persist.repository.ICommentRepository;
import cn.tedu.evaluation.management.pojo.entity.Comment;
import cn.tedu.evaluation.management.pojo.vo.CommentVO;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 处理评论数据的存储库实现类
 *
 * @author java@傲绝
 * @version 3.0
 */
@Slf4j
@Repository
public class CommentRepositoryImpl implements ICommentRepository {
    @Autowired
    private CommentMapper commentMapper;

    public CommentRepositoryImpl() {
        log.info("创建存储库对象：CommentRepositoryImpl");
    }
    @Override
    public int insert(Comment comment) {
        log.debug("开始执行【插入评论】的数据访问，参数：{}",comment);
        return commentMapper.insert(comment);
    }

    @Override
    public int deleteById(Long id) {
        log.debug("开始执行【根据ID删除评论】的数据访问，参数：{}", id);
        return commentMapper.deleteById(id);
    }

    @Override
    public int updateById(Comment comment) {
        log.debug("开始执行【更新评论】的数据访问，参数：{}", comment);
        return commentMapper.updateById(comment);
    }

    @Override
    public CommentVO getStandardById(Long id) {
        log.debug("开始执行【根据ID查询评论信息】的数据访问，参数：{}", id);
        return commentMapper.getStandardById(id);
    }

    @Override
    public List<CommentVO> listByResourceType() {
        log.debug("开始执行【查询评论列表】的数据访问");

        List<CommentVO> list = commentMapper.listByResourceType();

        return list;
    }

    @Override
    public List<CommentVO> listBySelect() {
//        return commentMapper.listBySelect();


        return commentMapper.selectList();
    }

    @Override
    public List<CommentVO> listAnonymousSelect() {
        log.debug("开始执行【查询匿名评论列表】的数据访问");
        return commentMapper.listAnonymousSelect();
    }

}
